package com.primary.useless;

import java.io.UnsupportedEncodingException;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class checkTest {
    static ResourceBundle bundle = ResourceBundle.getBundle("config\\log_message");
    public static boolean checknameandpassword(String usernameandpassword) {
        // In the username, a user can insert its information about username include numbers,letters and underline,
        // at the same time, the length of username will be limited 1 to 12 characters
        Pattern pattern = Pattern.compile("(^\\w+$)([^%&',;=?$\\x22]+){1,12}");
        Matcher matcher = pattern.matcher(usernameandpassword);
        return matcher.matches();
    }

    /*    private static boolean checkUserName(String checkUserName) {
        if (!length(checkUserName)) {
            return false;
        }
        for (int i = 0; i < checkUserName.length(); i++) {
            char cc = checkUserName.charAt(i);
            if (!isLetter(cc) && !isnumber(cc)) {
                return false;
            }
        }
        return true;
    }

    private static boolean isLetter(char s) {
        return  (isLowerCase(s) || isUpperCase(s)) ? true : false;
    }

    private static boolean isLowerCase(char s) {
        return (s >= 'a' && s <= 'z') ? true:false;
    }

    private static boolean length(String s) {
        return (s.length() >= 1 && s.length() <= 12) ? true:false;
    }

    private static boolean isnumber(char s) {
        return (s >= '0' && s <= '9') ?true:false;
    }

    private static boolean isUpperCase(char s) {
        return (s >= 'A' && s <= 'Z') ? true:false;
    }*/

    public static void main(String[] args) throws UnsupportedEncodingException {
//        System.out.println(checknameandpassword("12389%qwe"));
        String valueCN = new String(bundle.getString("MSG00002"));
        System.out.println(valueCN);
    }

}
